﻿Imports System.Data.OleDb
Public Class NganhDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "select * from ChuyenNganh"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub Insert(ByVal _nganh As NganhDTO)
        Dim strSQL As String = "Insert into ChuyenNganh(MaChuyenNganh,ChuyenNganh,Diengiai)  Values(N'" & _nganh.MaChuyenNganh & "',N'" & _nganh.ChuyenNganh & "',N'" & _nganh.DienGiai & "')"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub
    Public Shared Sub Delete(ByVal _nganh As NganhDTO)
        Dim strSQL As String = "delete from ChuyenNganh where MaChuyenNganh = '" & _nganh.MaChuyenNganh & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Update(ByVal _nganh As NganhDTO)
        Dim strSQL As String = "Update ChuyenNganh set ChuyenNganh = N'" & _nganh.ChuyenNganh & "', Diengiai = N'" & _nganh.DienGiai & "' where MaChuyenNganh = N'" & _nganh.MaChuyenNganh & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function SelectByNganh(ByVal _nganh As NganhDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from ChuyenNganh where ChuyenNganh like N'%" & _nganh.ChuyenNganh & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
End Class
